//
//  OrderInfoViewController.m
//  Manager
//
//  Created by 彭凯敏 on 15/8/18.
//  Copyright (c) 2015年 52xiaoluo. All rights reserved.
//

#import "OrderInfoViewController.h"
#import "SureOrderViewController.h"
#import "GiveUpOrderViewController.h"


@interface OrderInfoViewController ()

@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIView *contentView;


@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *expectLabel;


@property (weak, nonatomic) IBOutlet UILabel *roomLabel1;
@property (weak, nonatomic) IBOutlet UILabel *roomLabel2;
@property (weak, nonatomic) IBOutlet UILabel *roomStatus1;
@property (weak, nonatomic) IBOutlet UILabel *roomStatus2;



@property (weak, nonatomic) IBOutlet UILabel *jobLabel;
@property (weak, nonatomic) IBOutlet UILabel *liveLabel;

@property (weak, nonatomic) IBOutlet UILabel *remarkLabel;


@property (weak, nonatomic) IBOutlet UIButton *sureBtn;
@property (weak, nonatomic) IBOutlet UIButton *giveupBtn;
- (IBAction)clickPhone:(UIButton *)sender;
- (IBAction)clickSure:(UIButton *)sender;
- (IBAction)clickGiveUp:(UIButton *)sender;


@end

@implementation OrderInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self baseCtlSetTitle:@"预约单详情"];
    
    [_contentView setSizeHeight:_contentView.sizeHeight];
    [_contentView setSizeWidth:ScreenWidth];
    _scrollView.contentSize = CGSizeMake(ScreenWidth,_contentView.sizeHeight);
     
    [_scrollView addSubview:_contentView];
    
    [self resetUI];
}

- (void)resetUI
{
    _giveupBtn.layer.cornerRadius = IS320?23:IS667?27:30;
    _sureBtn.layer.cornerRadius = IS320?23:IS667?27:30;
    
    if (!_orderInfo) {
        return;
    }
    
    _nameLabel.text = [_orderInfo.name judgeWithBase:@""];
    _timeLabel.text = [NSString stringWithFormat:@"预约时间：%@",[KMGetDate timeFromNum:[NSString stringWithFormat:@"%llu",_orderInfo.viewTime/1000] andFormStr:@"YYYY-MM-dd HH:mm"]];
    _expectLabel.attributedText = [[NSString stringWithFormat:@"%d",(int)_orderInfo.expectPrice]judgeAttributePrice:@"心理价位："];
    
    _jobLabel.attributedText = [_orderInfo.job judgeAttributeBase:@"职       业："];
    _liveLabel.attributedText = [_orderInfo.checkInDays judgeAttributeBase:@"入住时间："];
    
    if (!_orderInfo.viewRooms) {
        _roomLabel1.attributedText = [@"" judgeAttributeRoom:@"约看房间："];
        _roomStatus1.text = @"";
        _roomLabel2.text = @"";
        _roomStatus2.text = @"";
    }
    else
    {
        int i = 0;
        while (i<_orderInfo.viewRooms.count) {
            RoomInfo *info = _orderInfo.viewRooms[i];
            if (i == 0) {
                [UIViewCategory newRoomLabel:_roomLabel1 andInfo:info andView:_scrollView];
                
                _roomStatus1.text = [UIViewCategory roomStatusWith:info];
                _roomLabel2.text = @"";
                _roomStatus2.text = @"";
            }
            if (i == 1) {
                
                [UIViewCategory newRoomLabel:_roomLabel2 andInfo:info andView:_scrollView];
                _roomStatus2.text = [UIViewCategory roomStatusWith:info];
            }
            i++;
        }
    }
    
    
    
    [UIViewCategory remarkLabelWith:_remarkLabel andText:_orderInfo.remark andView:_scrollView ];
    
    
}
- (IBAction)clickPhone:(UIButton *)sender {
    
    [KMCheckTel dialPhoneNumber:_orderInfo.phone withView:self.view];
}

- (IBAction)clickSure:(UIButton *)sender {
    SureOrderViewController *vc = [[SureOrderViewController alloc]init];
    
    vc.orderInfo = _orderInfo;
    vc.typeStr = @"0";
    [self.navigationController pushViewController:vc animated:YES];
}

- (IBAction)clickGiveUp:(UIButton *)sender {
    GiveUpOrderViewController *vc = [[GiveUpOrderViewController alloc]init];
    
    vc.orderInfo = _orderInfo;
    [self.navigationController pushViewController:vc animated:YES];

}

@end
